package son.nt.act1;

import java.util.ArrayList;

import son.nt.R;
import son.nt.adapter.ItemAreaAdapter;
import son.nt.entities.ItemDemo;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class SelectionActivity extends Activity implements OnItemClickListener {
	private Context mContext = null;
	private ListView lv;
	private ArrayList<ItemDemo> list = null;
	ItemAreaAdapter adapter = null;
	Handler mHandler = new Handler();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act1_selection);
		mContext = this;
		lv = (ListView) findViewById(R.id.lvSelection);
		list = new ArrayList<ItemDemo>();
		list.add(new ItemDemo(".act4.NotificationActivity", "date convert", "20/10/2012"));
		list.add(new ItemDemo(".act4.DateConvertActivity", "date convert", "16/10/2012"));
		list.add(new ItemDemo(".act4.DrawableResourceActivity", "rotate - shape - scale - drawable -resource", "18/8/2012"));
		list.add(new ItemDemo(".act4.IntentAction", "Action Intent: ACTION_DIAL, ACTION_VIEW, ACTION_CALL ..", "29/8/2012"));
		adapter = new ItemAreaAdapter(mContext, list);
		lv.setAdapter(adapter);
		lv.setOnItemClickListener(this);
	}
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		ItemDemo demo = list.get(position);
		Intent intent = new Intent();
		ComponentName mComponentName = new ComponentName(mContext.getApplicationInfo()
				.packageName, mContext.getApplicationInfo().packageName + demo.getName());
		intent.setComponent(mComponentName);
		startActivity(intent);
	}
	
}
